﻿@{
    Layout = "_MasterLayout";
}
<fieldset class="layui-elem-field" style="margin: 20px">
    <div class="layui-field-box">
        <table class="layui-hide" id="test" lay-filter="test"></table>
    </div>
</fieldset>

@section Scripts{
    <script src="~/layui-v2.5.5/layui/layui.js" charset="utf-8"></script>
    <script>
        layui.use('table', function () {
            var table = layui.table;
            table.render({
                elem: '#test'
                , url: '/api/QueryWorkPlan?state=5'
                , toolbar: false
                , title: 'Plan Table'
                , cols: [[
                    { field: 'id', title: 'ID', width: 80, fixed: 'left', unresize: true, sort: true }
                    , { field: 'teacherid', title: '教师ID', sort: true }
                    , { field: 'filename', title: '文件名称' }
                    , {field: 'committime', title: '提交时间',width: 200,sort: true} //, templet: '<div>{{d.committime.slice(0,7)}}</div>'
                    , { field: 'state', title: '计划状态' , templet: function (d) {
                         return statetostring(d.state)
                    }}
                    , { field: 'issue', title: '原因' }
                ]]
                , page: true
                , response: {
                    statusCode: 200 //重新规定成功的状态码为 200，table 组件默认为 0
                }
            });
            //监听行单击事件
            table.on('row(test)', function(obj){
                layui.use('layer', function () {
                    var layer = layui.layer;
                    layer.open({
                        type: 2,
                        title: false,
                        closeBtn: 1, //显示关闭按钮
                        shade: [0],
                        area: ['500px', '400px'],
                        offset: 'auto',
                        anim: 2,
                        content: ['/XZ/PlanDetail?id='+obj.data.id, 'no'], //iframe的url，no代表不显示滚动条
                    });
                });
            });

        });
        function statetostring(stateint)
        {
            switch (stateint)
            {
                case 0:
                    return "<span style='color:purple'>未审核</span>";
                break;
                case 1:
                    return "<span style='color:green'>同意</span>";
                    break;
                case 2:
                    return "<span style='color:blue'>待修正</span>";
                break;
                case 3:
                    return "<span style='color:yellow'>已修正</span>拒绝";
                break;
                case 4:
                    return "<span style='color:red'>驳回</span>拒绝";
                break;
                default:
                break;
            }
        }
    </script>
}